package com.doubao.wechat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doubao.wechat.entity.RefundOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 退款订单Mapper接口
 */
@Mapper
public interface RefundOrderMapper extends BaseMapper<RefundOrder> {

    /**
     * 根据商户退款单号查询退款订单
     *
     * @param outRefundNo 商户退款单号
     * @return 退款订单
     */
    @Select("SELECT * FROM refund_order WHERE out_refund_no = #{outRefundNo} LIMIT 1")
    RefundOrder selectByOutRefundNo(@Param("outRefundNo") String outRefundNo);

    /**
     * 根据商户订单号查询退款订单列表
     *
     * @param outTradeNo 商户订单号
     * @return 退款订单列表
     */
    @Select("SELECT * FROM refund_order WHERE out_trade_no = #{outTradeNo}")
    List<RefundOrder> selectByOutTradeNo(@Param("outTradeNo") String outTradeNo);

    /**
     * 根据微信退款单号查询退款订单
     *
     * @param refundId 微信退款单号
     * @return 退款订单
     */
    @Select("SELECT * FROM refund_order WHERE refund_id = #{refundId} LIMIT 1")
    RefundOrder selectByRefundId(@Param("refundId") String refundId);
}